﻿using System.Collections.ObjectModel;
using Bookvar.UI;

namespace Bookvar.Console
{
    public class DynamicTopicCollection : Collection<DynamicTopic>
    {
        private readonly TopicContentPresenter parent;

        public DynamicTopicCollection( TopicContentPresenter parent )
        {
            this.parent = parent;
        }

        protected override void ClearItems()
        {
            parent.Topic.SubTopics.Clear();
        }

        protected override void InsertItem( int index, DynamicTopic item )
        {
            parent.Topic.SubTopics.Insert( index, item.Topic );
        }

        protected override void RemoveItem( int index )
        {
            parent.Topic.SubTopics.RemoveAt( index );
        }

        protected override void SetItem( int index, DynamicTopic item )
        {
            parent.Topic.SubTopics[ index ] = item.Topic;
        }
    }
}